from Db import Db

class Install():
    
    def run(self):
        db  = Db()

        crt_tb_sql = """
            CREATE TABLE IF NOT EXISTS "yanjia_setting" (
                "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
                "code" varchar(100) NOT NULL DEFAULT '',
                "height" varchar(100) NOT NULL DEFAULT '',
                "length" varchar(100) NOT NULL DEFAULT '',
                "sepc" varchar(100) NOT NULL DEFAULT '',
                UNIQUE ("id" ASC)
            );
        """
        db.execute(crt_tb_sql)

        crt_tb_sql = """
            CREATE TABLE IF NOT EXISTS "projects" (
                "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
                "project_id" varchar(100) NOT NULL DEFAULT '',
                "name" varchar(100) NOT NULL DEFAULT '',
                "is_default" integer NOT NULL DEFAULT 0,
                UNIQUE ("id" ASC)
            );
        """
        db.execute(crt_tb_sql)

        crt_tb_sql = """
        CREATE TABLE IF NOT EXISTS "category" (
            "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
            "category_code" varchar(100) NOT NULL DEFAULT '',-- 分类编码
            "name" varchar(100) NOT NULL DEFAULT '',-- 分类名称
            "to_code" varchar(100) NOT NULL DEFAULT '',-- 对应码
            UNIQUE ("id" ASC)
        );
        """
        db.execute(crt_tb_sql)